home *** CD-ROM | disk | FTP | other *** search
- /*
- File: PMWindow.c
-
- Contains: QuickTime sample code
-
- Copyright: © 2000 by Apple Computer, Inc. All rights reserved
-
-
- */
-
- #include "PMWindow.h"
-
- //////////
- //
- // QTFrame_CreateMovieWindow
- // Create a new window to display the movie in.
- //
- //////////
-
- WindowReference CreateMovieWindow (void)
- {
- WindowReference myWindow = NULL;
- WindowObject myWindowObject = NULL;
-
- // create a new window to display the movie in
- myWindow = NewCWindow(NULL, // Window storage
- &gWindowRect, // Bounds
- gWindowTitle, // Window title
- false, // Show window yes? no?
- kWindowFloatProc, // WinProc ID
- (WindowPtr)-1L, // Place in front
- true, // Close box yes
- 0); // Reference constant
-
- // create a new window object associated with the new window
- QTFrame_CreateWindowObject(myWindow);
-
- return(myWindow);
- }
-
- //////////
- //
- // QTFrame_SizeWindowToMovie
- // Set the window size to exactly fit the movie and controller (if visible).
- //
- //////////
-
- void SizeWindowToMovie (WindowObject theWindowObject)
- {
- Rect myMovieBounds;
- Movie myMovie = NULL;
-
- #if TARGET_OS_WIN32
- gWeAreSizingWindow = true;
- #endif
-
- if (theWindowObject == NULL)
- goto bail;
-
- myMovie = (**theWindowObject).fMovie;
-
- if (myMovie == NULL)
- return;
-
- GetMovieBox(myMovie, // Movie specifier
- &myMovieBounds); // Movie bounds
-
- OffsetRect(&myMovieBounds, -myMovieBounds.left, -myMovieBounds.top);
-
- SetMovieBox(myMovie, // Movie specifier
- &myMovieBounds); // Movie bounds
-
- // make sure that the movie has a non-zero width;
- // a zero height is okay (for example, with a music movie with no controller bar)
- if (myMovieBounds.right - myMovieBounds.left == 0) {
- myMovieBounds.left = 0;
- myMovieBounds.right = QTFrame_GetWindowWidth((**theWindowObject).fWindow);
- }
-
- SizeWindow(QTFrame_GetWindowFromWindowReference((**theWindowObject).fWindow),
- myMovieBounds.right - myMovieBounds.left,
- myMovieBounds.bottom - myMovieBounds.top,
- true);
- bail:
- #if TARGET_OS_WIN32
- gWeAreSizingWindow = false;
- #endif
-
- return;
- }